package main

import "fmt"

<<<<<<< HEAD
// 泛型
func Add[T int | int32 | float32 | float64 | uint64](a, b T) T {
	return a + b
}

// 没有泛型之前是这样做的
=======
func Add[T int | int32 | float32 | float64 | uint64](a, b T) T {
	return a + b
}
>>>>>>> origin/dev
func IAdd(a, b interface{}) interface{} {
	switch a.(type) {
	case int:
		return a.(int) + b.(int)
	case int32:
		return a.(int32) + b.(int32)
	case float32:
		return a.(float32) + b.(float32)
	case float64:
		return a.(float64) + b.(float64)
	}
	return nil
}
func main() {
	//fmt.Println(Add[float32](1.2, 2.2))
	fmt.Println(IAdd(1.2, 2.3).(float64))
}
